#include <stdio.h>
#include <string.h>

struct xt
{
    char s0[32];
    int x;
};

struct xt myfunc(char * a, int b)
{
    struct xt xt;

    strcpy(&xt.s0[0], a);
    xt.x = b;

    return xt;
}

void main()
{
    struct xt xt;

    xt = myfunc("hello asm.", 0x666);
    printf("%s %x\n", &xt.s0[0], xt.x);
}

#if 0

/*
 * intel
 */
0000000000001189 <myfunc>:
    1189:	f3 0f 1e fa          	endbr64 
    118d:	55                   	push   %rbp		// rsp-=8, (rsp)=rbp
    118e:	48 89 e5             	mov    %rsp,%rbp	// rbp=rsp
    1191:	53                   	push   %rbx		// rsp-=8, (rsp)=rbx
    1192:	48 83 ec 58          	sub    $0x58,%rsp	// rsp-=0x58
    1196:	48 89 7d b8          	mov    %rdi,-0x48(%rbp)	// rbp-0x48=rdi
    119a:	48 89 75 b0          	mov    %rsi,-0x50(%rbp)	// rbp-0x50=rsi
    119e:	89 55 ac             	mov    %edx,-0x54(%rbp)	// rbp-0x54=edx
    11a1:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax	// rax=fs:0x28
    11a8:	00 00 
    11aa:	48 89 45 e8          	mov    %rax,-0x18(%rbp)	// rbp-0x18=rax
    11ae:	31 c0                	xor    %eax,%eax	// eax=0
    11b0:	48 8b 55 b0          	mov    -0x50(%rbp),%rdx	// rdx=rbp-0x50
    11b4:	48 8d 45 c0          	lea    -0x40(%rbp),%rax	// rax=rbp-0x40
    11b8:	48 89 d6             	mov    %rdx,%rsi	// rsi=rdx
    11bb:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    11be:	e8 ad fe ff ff       	callq  1070 <strcpy@plt>	// strcpy(rdi, rsi)
    11c3:	8b 45 ac             	mov    -0x54(%rbp),%eax	// exa=rbp-0x54
    11c6:	89 45 e0             	mov    %eax,-0x20(%rbp)	// rbp-0x20=eax
    11c9:	48 8b 45 b8          	mov    -0x48(%rbp),%rax	// rax=rbp-x048
    11cd:	48 8b 4d c0          	mov    -0x40(%rbp),%rcx	// rcx=rbp-0x40
    11d1:	48 8b 5d c8          	mov    -0x38(%rbp),%rbx	// rbx=rbp-0x38
    11d5:	48 89 08             	mov    %rcx,(%rax)	// (rax)=rcx		????
    11d8:	48 89 58 08          	mov    %rbx,0x8(%rax)	// (rax+8)=rbx
    11dc:	48 8b 4d d0          	mov    -0x30(%rbp),%rcx	// rcx=rbp-0x30
    11e0:	48 8b 5d d8          	mov    -0x28(%rbp),%rbx	// rbx=rbp-0x28
    11e4:	48 89 48 10          	mov    %rcx,0x10(%rax)	// (rax+0x10)=rcx	????
    11e8:	48 89 58 18          	mov    %rbx,0x18(%rax)	// (rax+0x18)=rbx	????
    11ec:	8b 55 e0             	mov    -0x20(%rbp),%edx	// dex=rbp-0x20
    11ef:	89 50 20             	mov    %edx,0x20(%rax)	// rax+0x20=edx
    11f2:	48 8b 45 e8          	mov    -0x18(%rbp),%rax	// rax=rbp-0x18
    11f6:	64 48 33 04 25 28 00 	xor    %fs:0x28,%rax	// rax=fs:0x28
    11fd:	00 00 
    11ff:	74 05                	je     1206 <myfunc+0x7d>
    1201:	e8 7a fe ff ff       	callq  1080 <__stack_chk_fail@plt>
    1206:	48 8b 45 b8          	mov    -0x48(%rbp),%rax
    120a:	48 83 c4 58          	add    $0x58,%rsp
    120e:	5b                   	pop    %rbx
    120f:	5d                   	pop    %rbp
    1210:	c3                   	retq   

0000000000001211 <main>:
    1211:	f3 0f 1e fa          	endbr64 
    1215:	55                   	push   %rbp
    1216:	48 89 e5             	mov    %rsp,%rbp
    1219:	48 83 ec 60          	sub    $0x60,%rsp
    121d:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    1224:	00 00 
    1226:	48 89 45 f8          	mov    %rax,-0x8(%rbp)		// rbp-0x8=rax
    122a:	31 c0                	xor    %eax,%eax		// eax=0
    122c:	48 8d 45 a0          	lea    -0x60(%rbp),%rax		// rax=rbp-0x60
    1230:	ba 66 06 00 00       	mov    $0x666,%edx		// edx=0x666
    1235:	48 8d 35 c8 0d 00 00 	lea    0xdc8(%rip),%rsi        # 2004 <_IO_stdin_used+0x4> rsi=rip+0xdc8
    123c:	48 89 c7             	mov    %rax,%rdi		// rdi=rax=rbp-0x60
    123f:	e8 45 ff ff ff       	callq  1189 <myfunc>		// myfunc(rsi, edx)
    1244:	48 8b 45 a0          	mov    -0x60(%rbp),%rax		// rax=rbp-0x60
    1248:	48 8b 55 a8          	mov    -0x58(%rbp),%rdx		// rdx=rbp-0x58
    124c:	48 89 45 d0          	mov    %rax,-0x30(%rbp)		// rbp-0x30=rax
    1250:	48 89 55 d8          	mov    %rdx,-0x28(%rbp)		// rbp-0x28=rdx
    1254:	48 8b 45 b0          	mov    -0x50(%rbp),%rax		// rax=rbp-0x50
    1258:	48 8b 55 b8          	mov    -0x48(%rbp),%rdx		// rdx=rbp-0x48
    125c:	48 89 45 e0          	mov    %rax,-0x20(%rbp)		// rbp-0x20=rax
    1260:	48 89 55 e8          	mov    %rdx,-0x18(%rbp)		// rbp-0x18=rdx
    1264:	8b 45 c0             	mov    -0x40(%rbp),%eax		// eax=rbp-0x40
    1267:	89 45 f0             	mov    %eax,-0x10(%rbp)		// rbp-0x10=eax
    126a:	8b 55 f0             	mov    -0x10(%rbp),%edx		// edx=rpb-0x10
    126d:	48 8d 45 d0          	lea    -0x30(%rbp),%rax		// rax=rbp-0x30
    1271:	48 89 c6             	mov    %rax,%rsi		// rsi=rax
    1274:	48 8d 3d 94 0d 00 00 	lea    0xd94(%rip),%rdi        # 200f <_IO_stdin_used+0xf> rdi=rip+0xd94
    127b:	b8 00 00 00 00       	mov    $0x0,%eax		// eax=0
    1280:	e8 0b fe ff ff       	callq  1090 <printf@plt>	// printf(rdi, rsi, edx)
    1285:	90                   	nop
    1286:	48 8b 45 f8          	mov    -0x8(%rbp),%rax		// rax=rbp-0x8
    128a:	64 48 33 04 25 28 00 	xor    %fs:0x28,%rax
    1291:	00 00 
    1293:	74 05                	je     129a <main+0x89>
    1295:	e8 e6 fd ff ff       	callq  1080 <__stack_chk_fail@plt>
    129a:	c9                   	leaveq 
    129b:	c3                   	retq   
    129c:	0f 1f 40 00          	nopl   0x0(%rax)


/*
 * arm
 */
00000000004005ac <myfunc>:
  4005ac:	a9ba7bfd 	stp	x29, x30, [sp, #-96]!
  4005b0:	910003fd 	mov	x29, sp
  4005b4:	f9000bf3 	str	x19, [sp, #16]		// sp+16=x19
  4005b8:	aa0803f3 	mov	x19, x8			// x19=x8
  4005bc:	f90017a0 	str	x0, [x29, #40]		// x29+40=x0
  4005c0:	b90027a1 	str	w1, [x29, #36]		// x29+36=w1
  4005c4:	9100e3a0 	add	x0, x29, #0x38		// x0=x29+0x38
  4005c8:	f94017a1 	ldr	x1, [x29, #40]		// x1=x29+40
  4005cc:	97ffffb1 	bl	400490 <strcpy@plt>	// strcpy(x0, x1)
  4005d0:	b94027a0 	ldr	w0, [x29, #36]		// w0=x29+36
  4005d4:	b9005ba0 	str	w0, [x29, #88]		// x29+88=w0
  4005d8:	aa1303e1 	mov	x1, x19			// x1=x19
  4005dc:	9100e3a0 	add	x0, x29, #0x38		// x0=x29+0x38
  4005e0:	a9400c02 	ldp	x2, x3, [x0]		// x2=x0, x3=x0+8
  4005e4:	a9000c22 	stp	x2, x3, [x1]		// x1=x2, x1+8=x3
  4005e8:	a9410c02 	ldp	x2, x3, [x0, #16]	// x2=x0, x3=x0+8, x0+=16
  4005ec:	a9010c22 	stp	x2, x3, [x1, #16]	// x1=x2, x1+8=x3, x1+=16
  4005f0:	b9402000 	ldr	w0, [x0, #32]		// w0=x0+32
  4005f4:	b9002020 	str	w0, [x1, #32]		// x1+32=w0
  4005f8:	f9400bf3 	ldr	x19, [sp, #16]		// x19=sp+16
  4005fc:	a8c67bfd 	ldp	x29, x30, [sp], #96	
  400600:	d65f03c0 	ret

0000000000400604 <main>:
  400604:	a9b97bfd 	stp	x29, x30, [sp, #-112]!
  400608:	910003fd 	mov	x29, sp			// x29=fp=sp
  40060c:	90000000 	adrp	x0, 400000 <_init-0x428>
  400610:	911c6000 	add	x0, x0, #0x718		// x0=400718
  400614:	910043a1 	add	x1, x29, #0x10		// x1=x29+0x10
  400618:	aa0103e8 	mov	x8, x1			// x8=x1
  40061c:	5280ccc1 	mov	w1, #0x666                 	// #1638
  400620:	97ffffe3 	bl	4005ac <myfunc>		// myfunc(x0, x1)
  400624:	910123a0 	add	x0, x29, #0x48		// x0=x29+0x48
  400628:	910043a1 	add	x1, x29, #0x10		// x1=x29+0x10
  40062c:	a9400c22 	ldp	x2, x3, [x1]		// x2=[x1], x3=[x1+8]
  400630:	a9000c02 	stp	x2, x3, [x0]		// [x0]=x2, [x0+8==x3
  400634:	a9410c22 	ldp	x2, x3, [x1, #16]	// x2=[x1], x3[x1+8], x1+=16
  400638:	a9010c02 	stp	x2, x3, [x0, #16]	// x0=23, x0+8=x3, x0+=16
  40063c:	b9402021 	ldr	w1, [x1, #32]		// w1=x1+32
  400640:	b9002001 	str	w1, [x0, #32]		// x0+32=w1
  400644:	b9406ba2 	ldr	w2, [x29, #104]		// w2=x29+104
  400648:	910123a1 	add	x1, x29, #0x48		// x1=x29+0x48
  40064c:	90000000 	adrp	x0, 400000 <_init-0x428>
  400650:	911ca000 	add	x0, x0, #0x728		// x0=400728
  400654:	97ffff93 	bl	4004a0 <printf@plt>	// printf(x0, x1, w2)
  400658:	d503201f 	nop
  40065c:	a8c77bfd 	ldp	x29, x30, [sp], #112
  400660:	d65f03c0 	ret
  400664:	00000000 	.inst	0x00000000 ; undefined

#endif
